<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>叩丁狼骡窝窝后台管理系统</title>
    <#include "../common/header.ftl" >
    <script>
        $(function () {
            $('#btn_query').click(function () {
                $('#searchForm').ajaxSubmit();
            })

            $('.updateStateBtn').click(function () {
                var id = $(this).data('id');
                var state = $(this).data('state');
                //没有表单,使用简单的ajax请求,
                $.post("/travel/updateState", {id: id, state: state}, function (data) {
                    if (data.success) {
                        window.location.reload();
                    } else {
                        data.msg;
                    }
                })
            })

            $('.lookBtn').click(function () {
                var id = $(this).data('id');
                $.get("/travel/getContent", {id: id}, function (data) {
                    $("#travelContent").html(data)

                })
                $('#inputModal').modal("show")
            })
        })
    </script>

</head>
<body>

<div class="container-fluid" style="margin-top: 20px">
    <#include "../common/top.ftl">
    <div class="row">
        <div class="col-sm-2">
            <#assign currentMenu="travel"/>
            <#include "../common/menu.ftl">
        </div>
        <div class="col-sm-10">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">待审核游记页面</h1>
                </div>
            </div>

            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/travel/list" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <select id="stateSelect" name="state" class="form-control">
                        <option value="1">待审核</option>
                        <option value="3">已拒绝</option>
                    </select>

                </div>
                <button id="btn_query" class="btn btn-default">
                    <span class="glyphicon glyphicon-search"></span> 查询
                </button>
            </form>

            <table class="table table-striped table-hover">
                <thead>
                <tr>
                    <td>编号</td>
                    <td>标题</td>
                    <td>封面</td>
                    <td>地点</td>
                    <td>作者</td>
                    <td>状态</td>
                </tr>
                </thead>
                <#list pageInfo.list as entity>
                    <tr>
                        <td>${entity_index}</td>
                        <td>${(entity.title)!}</td>
                        <td><img src="${(entity.coverUrl)!}" width="50px"></td>
                        <td>${(entity.dest.name)!}</td>
                        <td>${(entity.author.nickName)!}</td>
                        <td>${(entity.state==1)?string('待审核','已拒绝')}</td>

                        <td>
                            <a class="btn btn-default btn-xs updateStateBtn" href="JavaScript:;" data-state="2"
                               data-id="${entity.id}">
                                <span class="glyphicon glyphicon-tag"></span> 发布
                            </a>
                        <#--如果是拒绝状态,那么就不显示这个按钮-->
                            <#if entity.state !=3 >
                            <a class="btn btn-danger btn-xs updateStateBtn" href="javascript:;" data-state="3"
                               data-id="${entity.id}">
                                <span class=" glyphicon glyphicon-minus-sign"></span> 拒绝
                            </a>
                            </#if>
                            <a class="btn btn-info btn-xs lookBtn" href="JavaScript:;" data-id="${entity.id}">
                                <span class="glyphicon glyphicon-th"></span> 查看</a>
                        </td>
                    </tr>
                </#list>
            </table>
            <#include "../common/page.ftl"/>
        </div>
    </div>
</div>


<!-- 模态框必须作为body的子标签 -->
<div class="modal fade" id="inputModal" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel">查看文章内容</h4>
            </div>
            <div class="modal-body" id="travelContent">

            </div>
        </div>
    </div>
</div>


<!-- 大图显示 -->
<div id="ShowImage_Form" class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content">

            <div class="modal-body">
            </div>
        </div>
    </div>
</div>


<script>
    $("table img").click(function () {
        var src = $(this).attr("src");
        $("#ShowImage_Form .modal-body").html("<img src='" + src + "' class='carousel-inner img-responsive img-rounded' />");
        $("#ShowImage_Form").modal('show');
    })
</script>


</body>
</html>